﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:local="clr-namespace:EIA.SLClient.ProjectManage.Financial"
	xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
	xmlns:EIA_SLClient_Utility="clr-namespace:EIA.SLClient.Utility;assembly=EIA.SLClient.Utility"
	xmlns:EIA_SLClient_Utility_Behaviors="clr-namespace:EIA.SLClient.Utility.Behaviors;assembly=EIA.SLClient.Utility"
	xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
	mc:Ignorable="d"
	x:Class="EIA.SLClient.ProjectManage.Financial.InvoiceView"
	d:DesignWidth="600" d:DesignHeight="480">
	<UserControl.Resources>
		<local:InvoiceViewModel x:Key="InvoiceViewModelDataSource" />
		<DataTemplate x:Key="OptDataTemplate">
        	<StackPanel d:DesignWidth="140" Orientation="Horizontal">
                <HyperlinkButton Content="录入到款信息" CommandParameter="{Binding}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="8,0" BorderThickness="0">
                    <EIA_SLClient_Utility:BindingHelper.AncestorBinding>
                        <EIA_SLClient_Utility:AncestorBinding TargetPath="Command" AncestorPath="DataContext.InsertReceiptItemCommand" AncestorTypeName="DataGrid"/>
                    </EIA_SLClient_Utility:BindingHelper.AncestorBinding>
                </HyperlinkButton>
                <HyperlinkButton Content="编辑" CommandParameter="{Binding}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="8,0" BorderThickness="0">
                	<EIA_SLClient_Utility:BindingHelper.AncestorBinding>
                		<EIA_SLClient_Utility:AncestorBinding TargetPath="Command" AncestorPath="DataContext.UpdateItemCommand" AncestorTypeName="DataGrid"/>
                	</EIA_SLClient_Utility:BindingHelper.AncestorBinding>
                </HyperlinkButton>
                <HyperlinkButton Content="删除" CommandParameter="{Binding}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="8,0">
                    <EIA_SLClient_Utility:BindingHelper.AncestorBinding>
                        <EIA_SLClient_Utility:AncestorBinding TargetPath="Command" AncestorPath="DataContext.DeleteItemCommand" AncestorTypeName="DataGrid"/>
                    </EIA_SLClient_Utility:BindingHelper.AncestorBinding>
                </HyperlinkButton>
            </StackPanel>
		</DataTemplate>
	</UserControl.Resources>

	<Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource InvoiceViewModelDataSource}}">
		<i:Interaction.Triggers>
			<i:EventTrigger>
				<ei:CallMethodAction TargetObject="{Binding Mode=OneWay}" MethodName="OnLoad"/>
			</i:EventTrigger>
		</i:Interaction.Triggers>
		<Grid Margin="8" Background="#FFD4D4D4">
			<Grid.RowDefinitions>
				<RowDefinition Height="32"/>
				<RowDefinition/>
			</Grid.RowDefinitions>
			<sdk:DataGrid Grid.Row="1" ItemsSource="{Binding InvoiceCollection, Mode=TwoWay}">
				<sdk:DataGrid.Columns>
					<sdk:DataGridTextColumn Header="开票序号" Binding="{Binding InvoiceId}"/>
					<sdk:DataGridTextColumn Header="开票时间" Binding="{Binding InvoiceDate, StringFormat='yyyy-MM-dd'}"/>
					<sdk:DataGridTextColumn Header="开票金额" Binding="{Binding InvoiceAmount}"/>
					<sdk:DataGridTextColumn Header="开票号码" Binding="{Binding InvoiceNo}"/>
					<sdk:DataGridTemplateColumn Header="操作" CellTemplate="{StaticResource OptDataTemplate}"/>
				</sdk:DataGrid.Columns>
			</sdk:DataGrid>
			<HyperlinkButton Content="录入开票信息" HorizontalAlignment="Left" Margin="8,8,0,8" VerticalAlignment="Center" Command="{Binding InsertItemCommand}"/>
			<HyperlinkButton Content="重新载入" HorizontalAlignment="Right" Margin="0,8,8,8" d:LayoutOverrides="Height, VerticalMargin" Command="{Binding RetrieveItemsCommand}"/>
		</Grid>
		<local:InvoiceEditView/>
	</Grid>
</UserControl>
